package com.star.happy.user.controller;


import com.star.happy.user.entity.HappyUser;
import com.star.happy.user.service.HappyUserService;
import com.star.happy.wallpaper.entity.HappyWallpaper;
import com.star.happy.wallpaper.service.HappyWallpaperService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yueyuan
 * @since 2021-08-28
 */
@RestController
@RequestMapping("/happy-user")
public class HappyUserController {

    @Autowired
    private HappyUserService happyUserService;

    @DubboReference
    private HappyWallpaperService happyWallpaperService;

    @GetMapping("test")
    public String test(){
        return "ok";
    }

    @GetMapping("one")
    public HappyUser one(){
        HappyUser one = happyUserService.getById(1);
        return one;
    }

    @PostMapping("add")
    public String add(@RequestBody HappyUser happyUser){
        happyUserService.save(happyUser);
        return "ok";
    }


    @GetMapping("/dubbo")
    public HappyWallpaper dubbo(){
        return happyWallpaperService.getById(1l);
    }
}

